/*
 * Copyright (C) 2012, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.store.loaders;

/**
 *
 * @author Laurent WOUTERS
 */
public class BinaryStream {
    private java.io.InputStream inner;
    
    public BinaryStream(java.io.InputStream stream) {
        this.inner = stream;
    }
    
    public int readByte() throws java.io.IOException { return inner.read(); }
    
    public int readShort() throws java.io.IOException {
        int b0 = inner.read();
        int b1 = inner.read();
        return (b1*0x100 + b0);
    }
    
    public int readInt() throws java.io.IOException {
        int b0 = inner.read();
        int b1 = inner.read();
        int b2 = inner.read();
        int b3 = inner.read();
        return (b3*0x1000000 + b2*0x10000 + b1*0x100 + b0);
    }
    
    public void skipBytes(int count) throws java.io.IOException { inner.skip(count); }
}
